import axios from 'axios'
import URLS from '@/api/URLS.json'


let baseUrl = process.env.NODE_ENV=="production"?process.env.VUE_APP_SERVER_URL:"/api";
// 为当前环境中所有基于 axios 进行的非协议开头的请求，自动添加请求路径前缀
axios.defaults.baseURL = baseUrl;

const loadUserList = function() {
    // let p = axios.get(URLS.USER_LIST)
    // return p;
    return axios.get(URLS.USER_LIST)
               .then(function(response){
                    return response.data
               })
}
const loadCorsList = function() {
    return axios.get(URLS.CORS_LIST)
               .then(function(response){
                    return response.data
               })
}

// export default {
//     loadUserList,
// }
export default {
    install(Vue){
        Vue.prototype.$api = {
            loadUserList,loadCorsList
        }
    }
}